package com.graduation.adminservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.po.Case;
import com.graduation.pojo.query.CaseQuery;
import com.graduation.pojo.vo.CaseVO;
import com.graduation.service.CaseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/case")
@RequiredArgsConstructor
public class CaseController {

    private final CaseService caseService;

    @GetMapping("/page")
    public PageDTO<CaseVO> pageCases(CaseQuery query) {
        return caseService.pageCases(query);
    }

    @GetMapping("/{id}")
    public Case getCaseById(@PathVariable(name = "id") Long id) {
        return caseService.getCaseById(id);
    }

    @PostMapping
    public void saveCase(@RequestBody Case caseEntity) {
        caseService.saveCase(caseEntity);
    }

    @PutMapping
    public void updateCase(@RequestBody Case caseEntity) {
        caseService.updateCase(caseEntity);
    }

    @DeleteMapping("/{id}")
    public void deleteCase(@PathVariable(name = "id") Long id) {
        caseService.deleteCase(id);
    }

}
